In a computing system, host software (e.g., a hypervisor) may support a simulated computing environment (e.g., a virtualized environment) by way of implementing a virtual machine (VM) for guest software running on a host machine. The VM allows the guest software to execute as if the guest software was running directly on the physical hardware of the host machine.
The host machine generally includes a processor that is configured to operate in two modes: a non-root mode and a root mode. The host machine generally operates in the non-root mode to execute the guest software's non-privileged instructions, but may switch to the root mode upon detecting a privileged instruction that is to be managed by the hypervisor. Switching between modes is commonly referred to as trapping or as caused by an event that results in the so-called trap.
In a classic virtualized environment, multiple VMs are simultaneously executed over a base hypervisor at level zero (L0), which is the software level implemented directly over the host machine. In a nested virtualized environment, the L0 hypervisor can run multiple other hypervisors having corresponding virtual machines respectively nested at each level, such that a VM at level n+1, runs over a guest hypervisor at level n; and the guest hypervisor at level n runs over a host hypervisor at level n−1. The processor architecture may only support a single hypervisor mode, wherein a trap generated at any nested level is handled by the L0 hypervisor.
Referring to FIG. 1A, for example, a nested virtualized environment is illustrated in which the L0 hypervisor handles all traps that occur as the result of execution of the guest hypervisors and the guests, at L1 and L2 respectively. That is, L0 is designated to handle all traps generated at any level regardless of the depth of the nested virtualization. FIG. 1B is an illustration of the path of execution in the nested environment of FIG. 1A, where any trap occurring at levels L1, L2, L3, . . . , Ln results in the execution path dropping to L0.
As such, if the host does not have the architectural support for nested virtualization, additional hardware or software mechanisms will have to be implemented at a cost. For example, in order to run two levels of virtualization, some hypervisors are equipped with complex software schemes called extensions which multiplex the single level of virtualization supported by the host across the nested levels by forwarding and translating the specifications of the VMs that are to be launched at a higher level to a lower level hypervisor.
In the scenario with n virtualization levels, n−2 levels are needed to implement the software extensions. In other words, the source code of n−2 hypervisors must be modified. The additional overhead introduced and the persistence switches and interactions between the different levels and modes of operation can adversely affect system performance.